<?php


namespace App\Utils;


use Illuminate\Support\Facades\Storage;

class MyLog
{

    public static function info($message)
    {
        self::write($message,'INFO');
    }

    public static function error($message)
    {
        self::write($message,'ERROR');
    }

    private static function write($message,$type='INFO')
    {
        $path = storage_path("logs");
        if (!file_exists($path)) mkdir($path,0777,true);
        $file = $path .'/'. date("Y-m-d").'.log';
        $message = date("Y-m-d H:i:s") . " [$type] : " . $message . "\n";
        file_put_contents($file,$message,FILE_APPEND);
    }

}
